library(limma)
library(statmod)
data <- read.table("methy_sample_info.txt", header=T, sep="\t")
attach(data)
Factor <- factor(Factor)
Treat <- factor(Disease,levels=c("C","T"))
design <- model.matrix(~Factor+Treat)
eset <- read.table("WR_BRCA_normalized_450_methylation_tumor_normal_only.txt", header=T, sep="\t")
ind <- rowSums(is.na(eset))
eset<-eset[which(ind<74),]
i<-1
result<-c()
while(i<=length(colnames(eset)))
{
	result<-c(result,gsub("\\.","-", colnames(eset)[i]))
	i<-i+1
}
colnames(eset)<-result
fit <- lmFit(eset, design)
fit <- eBayes(fit)
tt<-toptable(fit, coef="TreatT", n=nrow(eset))
selected.rows<-rownames(eset[as.numeric(rownames(tt)),])
descript<-eset[selected.rows,]
result<-cbind(descript,tt)
fc<-(2**abs(tt[,"logFC"]))*(tt[,"logFC"]/abs(tt[,"logFC"]))
descript <-as.matrix(descript)
tt <-as.matrix(tt)
result<-cbind(descript,fc,tt)
write.table(result,"methy_ebayes_result.txt",sep="\t",quote=F)
